<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<script language="javascript" src="../script/common.js" type="text/javascript"></script>
		<meta name="author" content="liunan">
		<title>撤销库存单据</title>
	</head>
<script type="text/javascript">
	var org = Common.cOrg();		//当前单位	
	var qt = {};					//数据表格对象
	var inited = false;				//初始化标志		
	var cardType;					//全局变量(单据)
	var ids = 0; 					//全局变量id
	var cardBill;
	
	function load(){
		Eui.showNavigation();
		setPages(["listview","amply"]);
	}
	//查询单据是否可以被撤销
	function onQuery(){
		if(!checkForm("content_page"))return;
		var id = $("o.serialID").value;
		DWR.call("cardStoreService.getBillRepeal",id,function(v){	
			cardBill = v;
			var butCancel = "";
			if(cardBill.cancelable){
				butCancel= "<button type='button' onclick='parent.remove()'>撤 销</button>"
			}
			switchPage("amply");
			requestframe.document.location.href = "card_bill_detail.html?cardBillId="+cardBill.id+"&readOnly=true"+"&butCancel="+butCancel;
		});
	}
	function showData(){	
		qt.showTable();
	}
	//改变状态（撤销）
	function remove(){
		if(showQuestion("请确认是否撤销?")){
			var id = cardBill.id; 
			if(cardBill.billType == Constants.CARD_BILL_TYPE_IN){
				if(cardBill.subType == CardBillSubType.IN_INTERNAL){
					DWR.call("cardStoreService.rollbackWarehousing",id,null,function(){
						showInformation("撤销成功");
						switchPage('listview');
					});	
				}else{
					DWR.call("cardStoreService.rollbackWarehousingAfterManufacture",id,null,function(){
						showInformation("撤销成功");
						switchPage('listview');
					});	
				} 		
			}else if(cardBill.billType == Constants.CARD_BILL_TYPE_OUT){
				DWR.call("cardStoreService.rollbackDelivery",id,null,function(){
					showInformation("撤销成功");
					switchPage('listview');
				});	
			}else if(cardBill.billType == Constants.CARD_BILL_TYPE_ADJUST){
				DWR.call("cardStoreService.rollbackAjustInventory",id,null,function(){
					showInformation("撤销成功");
					switchPage('listview');
				});
			}
			$("content_page").reset();
		}
	}
	function onBack(){
		switchPage('listview');
	}
</script>
	<body onload="load()">
	<!--查询静态页面部分-->
	<div class="nav"><div id="nav">&nbsp;</div></div>
	<div id="listview">
		<form id="content_page" name="content_page">
			<div class="form">
				<div class="formTitle">撤销库存单据 </div>
				<table cellSpacing=0 cellPadding=4 width="100%" border=0>
					<tr>
						<td><label>单据编号</label> <input type="text" name="o.serialID" onblur="checkV(this,'number',true)" maxlength="12"><span class="des">*</span></td>
					</tr>
				</table>
			</div>
			<p><button type="button" onclick="onQuery()">查 询</button></p>
		</form>
	</div>
	<div id="amply" style="display:none;">
		<iframe id="requestframe" name="requestframe" style="width:100%;height:93%;overflow:auto;" frameborder=0 src=""></iframe>
	</div>
</body>
</html>